.class public Lcom/inmobi/androidsdk/impl/metric/Logger;
.super Ljava/lang/Object;
.source "Logger.java"


# static fields
.field private static a:Ljava/lang/String;

.field public static action:Lcom/inmobi/androidsdk/impl/metric/MetricAction;

.field private static b:Ljava/lang/Integer;


# direct methods
.method static constructor <clinit>()V
    .locals 2

    .prologue
    const/4 v1, 0x0

    .line 9
    sput-object v1, Lcom/inmobi/androidsdk/impl/metric/Logger;->a:Ljava/lang/String;

    .line 10
    const v0, 0x7ffffffe

    invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v0

    sput-object v0, Lcom/inmobi/androidsdk/impl/metric/Logger;->b:Ljava/lang/Integer;

    .line 11
    sput-object v1, Lcom/inmobi/androidsdk/impl/metric/Logger;->action:Lcom/inmobi/androidsdk/impl/metric/MetricAction;

    return-void
.end method

.method public constructor <init>()V
    .locals 0

    .prologue
    .line 8
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static getUrl()Ljava/lang/String;
    .locals 1

    .prologue
    .line 14
    sget-object v0, Lcom/inmobi/androidsdk/impl/metric/Logger;->a:Ljava/lang/String;

    return-object v0
.end method

.method public static logEvent(Landroid/content/Context;Lcom/inmobi/androidsdk/impl/metric/EventLog;)V
    .locals 6
    .parameter
    .parameter

    .prologue
    .line 18
    invoke-static {p0}, Lcom/inmobi/androidsdk/impl/metric/Storage;->readNumberOfEventsAndTimeStampFromPersistent(Landroid/content/Context;)V

    .line 19
    invoke-static {p0}, Lcom/inmobi/androidsdk/bootstrapper/Initializer;->getConfigParams(Landroid/content/Context;)Lcom/inmobi/androidsdk/bootstrapper/ConfigParams;

    move-result-object v0

    invoke-virtual {v0}, Lcom/inmobi/androidsdk/bootstrapper/ConfigParams;->getMetric()Lcom/inmobi/androidsdk/bootstrapper/MetricConfigParams;

    move-result-object v0

    .line 21
    sget-object v1, Lcom/inmobi/androidsdk/impl/metric/Queuer;->queuer:Lcom/inmobi/androidsdk/impl/metric/Queuer;

    invoke-virtual {v1, p1}, Lcom/inmobi/androidsdk/impl/metric/Queuer;->log(Lcom/inmobi/androidsdk/impl/metric/EventLog;)V

    .line 23
    sget-object v1, Lcom/inmobi/androidsdk/impl/metric/Queuer;->queuer:Lcom/inmobi/androidsdk/impl/metric/Queuer;

    iget-wide v1, v1, Lcom/inmobi/androidsdk/impl/metric/Queuer;->number:J

    invoke-virtual {v0}, Lcom/inmobi/androidsdk/bootstrapper/MetricConfigParams;->getDumpThreshhold()I

    move-result v3

    int-to-long v3, v3

    cmp-long v1, v1, v3

    if-ltz v1, :cond_0

    .line 24
    invoke-static {p0}, Lcom/inmobi/androidsdk/impl/metric/Storage;->saveLocalCache(Landroid/content/Context;)V

    .line 29
    :cond_0
    sget-wide v1, Lcom/inmobi/androidsdk/impl/metric/Storage;->events:J

    invoke-virtual {v0}, Lcom/inmobi/androidsdk/bootstrapper/MetricConfigParams;->getMaxInQueue()I

    move-result v3

    int-to-long v3, v3

    cmp-long v1, v1, v3

    if-gez v1, :cond_1

    sget-wide v1, Lcom/inmobi/androidsdk/impl/metric/Storage;->timestamp:J

    invoke-virtual {v0}, Lcom/inmobi/androidsdk/bootstrapper/MetricConfigParams;->getNextRetryInterval()I

    move-result v0

    int-to-long v3, v0

    add-long v0, v1, v3

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v2

    const-wide/16 v4, 0x3e8

    div-long/2addr v2, v4

    cmp-long v0, v0, v2

    if-gtz v0, :cond_2

    .line 32
    :cond_1
    new-instance v0, Ljava/lang/Thread;

    new-instance v1, Lcom/inmobi/androidsdk/impl/metric/Logger$a;

    invoke-direct {v1, p0}, Lcom/inmobi/androidsdk/impl/metric/Logger$a;-><init>(Landroid/content/Context;)V

    invoke-direct {v0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    invoke-virtual {v0}, Ljava/lang/Thread;->start()V

    .line 39
    :cond_2
    return-void
.end method

.method public static startNewSample(Landroid/content/Context;)Z
    .locals 4
    .parameter

    .prologue
    const/4 v0, 0x0

    .line 42
    sget-object v1, Lcom/inmobi/androidsdk/impl/metric/Logger;->b:Ljava/lang/Integer;

    monitor-enter v1

    .line 43
    :try_start_0
    sget-object v2, Lcom/inmobi/androidsdk/impl/metric/Logger;->b:Ljava/lang/Integer;

    sget-object v2, Lcom/inmobi/androidsdk/impl/metric/Logger;->b:Ljava/lang/Integer;

    invoke-virtual {v2}, Ljava/lang/Integer;->intValue()I

    move-result v2

    add-int/lit8 v2, v2, 0x1

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    sput-object v2, Lcom/inmobi/androidsdk/impl/metric/Logger;->b:Ljava/lang/Integer;

    .line 44
    sget-object v2, Lcom/inmobi/androidsdk/impl/metric/Logger;->b:Ljava/lang/Integer;

    invoke-virtual {v2}, Ljava/lang/Integer;->intValue()I

    move-result v2

    invoke-static {p0}, Lcom/inmobi/androidsdk/bootstrapper/Initializer;->getConfigParams(Landroid/content/Context;)Lcom/inmobi/androidsdk/bootstrapper/ConfigParams;

    move-result-object v3

    invoke-virtual {v3}, Lcom/inmobi/androidsdk/bootstrapper/ConfigParams;->getMetric()Lcom/inmobi/androidsdk/bootstrapper/MetricConfigParams;

    move-result-object v3

    invoke-virtual {v3}, Lcom/inmobi/androidsdk/bootstrapper/MetricConfigParams;->getSamplingFactor()I

    move-result v3

    if-lt v2, v3, :cond_1

    .line 46
    const/4 v0, 0x0

    invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v0

    sput-object v0, Lcom/inmobi/androidsdk/impl/metric/Logger;->b:Ljava/lang/Integer;

    .line 49
    sget-object v0, Lcom/inmobi/androidsdk/impl/metric/Logger;->action:Lcom/inmobi/androidsdk/impl/metric/MetricAction;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    if-eqz v0, :cond_0

    .line 51
    :try_start_1
    sget-object v0, Lcom/inmobi/androidsdk/impl/metric/Logger;->action:Lcom/inmobi/androidsdk/impl/metric/MetricAction;

    invoke-interface {v0}, Lcom/inmobi/androidsdk/impl/metric/MetricAction;->metricCalcEvent()V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    .line 57
    :cond_0
    :goto_0
    const/4 v0, 0x1

    :try_start_2
    monitor-exit v1

    .line 60
    :goto_1
    return v0

    :cond_1
    monitor-exit v1

    goto :goto_1

    .line 61
    :catchall_0
    move-exception v0

    monitor-exit v1
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    throw v0

    .line 53
    :catch_0
    move-exception v0

    goto :goto_0
.end method
